﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using SWSoft.Framework.Web;
using System.IO;
using System.Configuration;

namespace TradeTestWeb
{
    /// <summary>
    /// loger 的摘要说明
    /// </summary>
    public class loger : Handler
    {
        public string getyblist()
        {
            var director = new DirectoryInfo(ConfigurationManager.AppSettings["SIIMServer"]);
            var json = "";
            foreach (var item in Directory.GetDirectories(director.FullName + "\\XmlLog"))
            {
                json += string.Format("{{'name':'{0}'}},", Path.GetFileName(item));
            }
            return "[" + json.Substring(0, json.Length - 1) + "]";
        }

        public string getloglist(string ylbxid, string date)
        {
            var director = new DirectoryInfo(ConfigurationManager.AppSettings["SIIMServer"]);
            var json = "";
            foreach (var item in Directory.GetFiles(director.FullName + "\\XmlLog\\" + ylbxid, DateTime.Parse(date).ToString("yyyyMMdd") + "*"))
            {
                var fileinfo = new FileInfo(item);
                json += string.Format("{{'name':'{0}','context':'{1}','size':'{2}'}},", fileinfo.Name, ylbxid + "|" + fileinfo.Name, fileinfo.Length);
            }
            if (json==string.Empty)
            {
                return "[]";
            }
            return "[" + json.Substring(0, json.Length - 1) + "]";
        }
    }
}